<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Requirement extends Model
{
    public function features()
    {
        return $this->belongsToMany(Feature::class,'feature_requirement', 'requirement_id', 'feature_id');
    }

    public function module()
    {
        return $this->belongsTo(Module::class);
    }

    public function adminUserRequirements()
    {
        return $this->hasMany(AdminUserRequirement::class,'requirement_id','id');
    }

    public function adminUser()
    {
        return $this->belongsToMany(AdminUser::class,'admin_user_requirement','requirement_id','admin_user_id');
    }

    public function orderColor()
    {
        return $this->belongsTo(OrderColor::class,'order_color_id','id');
    }

    public function getXuqiutaolunAttribute($value)
    {
        return explode(',', $value);
    }

    public function setXuqiutaolunAttribute($value)
    {
        $this->attributes['xuqiutaolun'] = implode(',', $value);
    }
    public function getHouduankaifaAttribute($value)
    {
        return explode(',', $value);
    }

    public function setHouduankaifaAttribute($value)
    {
        $this->attributes['houduankaifa'] = implode(',', $value);
    }
    public function getQianduankaifaAttribute($value)
    {
        return explode(',', $value);
    }

    public function setQianduankaifaAttribute($value)
    {
        $this->attributes['qianduankaifa'] = implode(',', $value);
    }
    public function getUishejiAttribute($value)
    {
        return explode(',', $value);
    }

    public function setUishejiAttribute($value)
    {
        $this->attributes['uisheji'] = implode(',', $value);
    }
    public function getCeshiAttribute($value)
    {
        return explode(',', $value);
    }

    public function setCeshiAttribute($value)
    {
        $this->attributes['ceshi'] = implode(',', $value);
    }
    public function getBushushangxianAttribute($value)
    {
        return explode(',', $value);
    }

    public function setBushushangxianAttribute($value)
    {
        $this->attributes['bushushangxian'] = implode(',', $value);
    }
}
